package chatModel;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.logging.Level;
import java.util.logging.Logger;

/* 
 * @author Yahya-Albaba
*/

public class User {

	/**
	 * @param  username consists of a string representing the user name  
	 * @param  hostname consists of the host name!!!
	 * @param  IPaddr consists of the IP address of the user
	*/
	
    private String username;
    private String hostname;
    private InetAddress IPaddr;

    /**
	 * This class represents the user and the information of this user
	*/
    public User(String username, String hostname) {
        this.username = username;
        this.hostname = hostname;
        try {
            this.IPaddr = InetAddress.getByName(hostname);
        } catch (UnknownHostException ex) {
            Logger.getLogger(User.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
	 * This method allows us to get the user name
	*/
    public String getUsername() {
        return username;
    }
    
    /**
   	 * This method allows us to get the host name
   	*/

    public String getHostname() {
        return hostname;
    }

    /**
   	 * This method allows us to get the IP address
   	*/
    public InetAddress getIPaddr() {
        return IPaddr;
    }

    
    @Override
    public String toString() {
        return username + "@" + hostname;
    }
}

